﻿using System;
using System.Collections;
using UnityEngine;

public class RecordUnit : ReplayUnit
{
    public int speed = 10;
    Vector3 lastDir = Vector3.zero;
    Vector3 curDir = Vector3.zero;

    public void Move(float x, float z)
    {
        var playMode = GameMgr.Instance.PlayMode;
        if (playMode != PlayMode.Record)
            return;

        curDir.x = x;
        curDir.y = 0;
        curDir.z = z;

        if (curDir != lastDir)
        {
            var velocity = curDir * speed * Time.deltaTime;
            var command = new MoveCmd()
            {
                Velocity = velocity.ToRVector3(),
            };
            DoCmd(CmdEnum.Move, command);
        }
        lastDir.x = curDir.x;
        lastDir.y = curDir.y;
        lastDir.z = curDir.z;
    }
}
